import 'dart:ui';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

/// 评论输入框
class CommentBar extends StatelessWidget {
  final TextEditingController controller;
  final String hintText;
  final ValueChanged<String> onChanged;
  final VoidCallback onSendPressed;

  const CommentBar({
    Key key,
    @required this.controller,
    this.onChanged,
    this.hintText,
    this.onSendPressed,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return SafeArea(
      child: Row(
        children: [
          Expanded(
            child: Padding(
              padding: EdgeInsets.symmetric(horizontal: 16, vertical: 10),
              child: TextField(
                autofocus: false,
                keyboardType: TextInputType.multiline,
                cursorColor: Theme.of(context).primaryColor,
                autocorrect: false,
                controller: controller,
                decoration: InputDecoration(
                  hintText: hintText,
                  isDense: true,
                  border: InputBorder.none,
                  fillColor: Colors.grey[100],
                  filled: true,
                  contentPadding:
                      EdgeInsets.symmetric(horizontal: 16, vertical: 8),
                  enabledBorder: OutlineInputBorder(
                    borderRadius: BorderRadius.all(Radius.circular(5)),
                    borderSide: BorderSide(color: Colors.transparent),
                  ),
                  focusedBorder: OutlineInputBorder(
                    borderRadius: BorderRadius.all(Radius.circular(5)),
                    borderSide: BorderSide(color: Colors.transparent),
                  ),
                ),
                onChanged: onChanged,
              ),
            ),
          ),
          Container(
            padding: EdgeInsets.only(right: 16),
            height: 35,
            child: ElevatedButton(
              child: Text('评论'),
              onPressed: onSendPressed,
            ),
          ),
        ],
      ),
    );
  }
}
